// @flow
import React, { Component } from 'react'
import styles from './Toolbar.css'
import { Input, Button, Form } from 'antd'
const FormItem = Form.Item
type Props = {
  form: Object
}
class ToolBar extends Component {
  props: Props
  handleSubmit: Function
  constructor (props: Props) {
    super(props)
    this.handleSubmit = this.handleSubmit.bind(this)
  }
  handleSubmit (e) {
    e.preventDefault()
    this.props.form.validateFields((err, values) => {
      if (!err) {
        // console.log('Received values of form: ', values)
      }
    })
  }
  render () {
    const { getFieldDecorator } = this.props.form
    return (
      <Form layout='inline' className={styles['tool-bar']}>
        <FormItem>
          {getFieldDecorator('name')(
            <Input placeholder='设备名称' />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('deviceNo')(
            <Input placeholder='设备编号' />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('type')(
            <Input placeholder='设备类型' />
          )}
        </FormItem>
        <FormItem>
          {getFieldDecorator('spec')(
            <Input placeholder='设备型号' />
          )}
        </FormItem>
        <Button icon='search' onClick={this.handleSubmit} style={{ marginTop: '2px' }} />
      </Form>
    )
  }
}

export default Form.create()(ToolBar)
